var Sequelize = require('sequelize');
var conf = require('../config');
var sequelize = new Sequelize(conf.mysql.database, conf.mysql.user, conf.mysql.password, {
    host: conf.mysql.host,
    port: conf.mysql.port,
    dialect: 'mysql',
    pool: {
        maxConnections: 200,
        minConnections: 20,
        maxIdleTime: 2000
    },
    timezone: '+08:00',
    logging: false,
    maxConcurrentQueries: 100
});

var gps_info = sequelize.define('T_GPSINFO', {
    unificationcode:Sequelize.INTEGER,
    g_time:Sequelize.DATE,
    longitude:Sequelize.DOUBLE,
    latitude:Sequelize.DOUBLE,
    way:Sequelize.STRING,
    mileage:Sequelize.INTEGER,
    status:Sequelize.INTEGER,
    speed:Sequelize.INTEGER,
    wiringstatus:Sequelize.INTEGER,
    onoff:Sequelize.INTEGER,
    writetime:Sequelize.DATE,
    valid:Sequelize.STRING,
    acc:Sequelize.INTEGER,
    location:Sequelize.STRING,
    longitude_e:Sequelize.DOUBLE,
    latitude_e:Sequelize.DOUBLE,
    longitude_b:Sequelize.DOUBLE,
    latitude_b:Sequelize.DOUBLE,
},{
    tableName: 'T_GPSINFO',
    timestamps: false
});

sequelize.sync();

module.exports = {
    sequelize:sequelize,
    gps_info: gps_info,
};